package stackdemo;

import java.util.Arrays;

public class MyStack {
    public int [] elem;
    public int usedSize;

    public MyStack(){
        elem = new int [10];
    }

    public boolean isFull(){
        return usedSize == elem.length;
    }

    public void push(int val){
        //如果满了，进行扩容
        if(isFull()){
            elem = Arrays.copyOf(elem,elem.length*2);
        }
        //入栈
        elem[usedSize] = val;
        //us++
        usedSize++;
    }

}
